<?php
	$filterUrls = array(
		__('Newest')=> array('sort'=>'Review.created','direction'=>'desc'),
		__('Oldest')=>array('sort'=>'Review.created','direction'=>'asc'),
		__('Highest Rated')=>array('sort'=>'Review.avg_score','direction'=>'desc'),
		__('Lowest Rated')=>array('sort'=>'Review.avg_score','direction'=>'asc'),
		__('Most Helpful')=>array('sort'=>'Review.vote_count','direction'=>'desc')
	);
	$pagingUrl = $this->getPagingUrl();
	$presentUrl = $appHtml->url(am($pagingUrl,array_diff_key($this->params['named'],array("page"=>null))));
	
	foreach($filterUrls as &$filterUrl)
	{
		$filterUrl = am(am($this->params['named'],$this->params['pass']),$filterUrl);
		$filterUrl['page'] = null;
		$filterUrl = $appHtml->url($filterUrl);			
	}
	
	$filterUrls = array_flip($filterUrls);
	$paginator->options(array('url'=>$this->getPagingUrl()));
?>

<div class="index_filter">
<?php 
	echo $form->input('review_filter',array('label'=>__('Sort By'),'type'=>'select','options'=>$filterUrls,'onchange'=>"$('#review_sortLink').attr('href',$(this).val()).trigger('click')",'value'=>$presentUrl));
?>
<a style = 'display: none;' id="review_sortLink" class="paging_ajaxify"></a>
</div>

<div class="clear"></div>